/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package au.csiro.nt.psdp.actions.user;

import au.csiro.nt.psdp.actions.PdspActionSupport;

import javax.servlet.http.HttpSession;
import javax.servlet.http.Cookie;
import org.acegisecurity.ui.rememberme.TokenBasedRememberMeServices;

/**
 *
 */
public class LogoutAction extends PdspActionSupport
{


    public String execute() throws Exception
    {
        HttpSession session = getRequest().getSession(false);

        if (session != null)
        {
            /*when the user logout, also stop the session*/


            session.invalidate();
            Cookie terminate = new Cookie(TokenBasedRememberMeServices.ACEGI_SECURITY_HASHED_REMEMBER_ME_COOKIE_KEY, null);
            terminate.setMaxAge(0);
            getResponse().addCookie(terminate);
        }
        return SUCCESS;
    }
}
